import java.util.HashMap;
import java.util.Map;
import java.util.Stack;


class Solution {

    class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;
        TreeNode() {}
        TreeNode(int val) { this.val = val; }
        TreeNode(int val, TreeNode left, TreeNode right) {
            this.val = val;
            this.left = left;
            this.right = right;
        }

    }
    Map<Integer,Integer> map=new HashMap<>();


    public TreeNode buildTree(int[] inorder, int[] postorder) {
        for(int i=0;i<inorder.length;i++){
            map.put(inorder[i],i);
        }
        int n=inorder.length;
        return buildert(inorder,postorder,0,n-1,0,n-1);
    }
    public TreeNode buildert(int[] inorder, int[] postorder, int inleft,int inright,int postleft,int postright){
        if(postright<0||inleft>inright)return null;

        int root=postorder[postright];
        TreeNode root1=new TreeNode(root);
        int size=map.get(root);
        root1.left=buildert(inorder,postorder,inleft,size-1,postleft,postleft+size-inleft-1);
        root1.right=buildert(inorder,postorder,size+1,inright,postleft+size-inleft,postright-1);
        return root1;
    }
    public void preOrder(TreeNode root){
        if(root==null)return;
        System.out.println(root.val);
        preOrder(root.left);
        preOrder(root.right);

    }
}



public class Test001 {
    public static int evalRPN(String[] tokens) {
        if (tokens.length == 0)
            return 0;
        Stack<Integer> stack = new Stack<>();
        for (int i = 0; i < tokens.length; i++) {
            String ret = tokens[i];
            if (ret.length()==1&&(ret.charAt(0) == '/' || ret.charAt(0) == '-' || ret.charAt(0) == '+' || ret.charAt(0) == '*')){
                int a = stack.pop();
                int b = stack.pop();
                int c = isopration(b, a, ret);
                stack.push(c);
            } else {
                stack.push(Integer.parseInt(ret));
            }
        }
        return stack.peek();
    }

    public static int isopration(int a, int b, String c) {
        int op = 0;
        switch (c) {
            case "-":
                op = a - b;
                break;
            case "+":
                op = a + b;
                break;
            case "/":
                op = a / b;
                break;
            case "*":
                op = a * b;
                break;

        }
        return op;
    }

        public static String reverseWords(String s) {
            StringBuffer sb=new StringBuffer();
            String[] ret=s.split(" ");
            for(int i=ret.length-1;i>=0;i--){
                String ret1=ret[i];
                if(ret1.length()==0||ret1.charAt(0)==' ') continue;
                sb.append(ret1).append(" ");
            }
            return sb.toString().substring(0,sb.length()-1);
        }

    public static void main(String[] args) {
        String[] tokens = {"10","6","9","3","+","-11","*","/","*","17","+","5","+"};
     int a=evalRPN(tokens);
        System.out.println(a);
        String ret="fgsdhjk        dfgjsk";
        String[] ARR=ret.split(" ");
        System.out.println(ARR[0]);

//       Solution solution=new Solution();
//       int[] inorder={9,3,15,20,7};
//       int[] postorder={9,15,7,20,3};
//       Solution.TreeNode root=solution.buildTree(inorder,postorder);
//        solution.preOrder(root);
//        HashMap<Integer,Integer> map=new HashMap<>();
//         map.put(1,2);
//         map.put(2,3);
//         char ch='2';
//         int a=ch-'0';
//         System.out.println(a);
    }
}
